void main() {
  List intList = [1, 2];
  try {
    print(intList[2]);
  } on RangeError {
    // 捕获特定异常
    print(intList[1]);
    rethrow; // 可以在捕获后再次抛出该异常
  } catch (e) {
    print(e.toString());
  } finally {
    print("finish");
  }

  //异常2
  try {
    double i = 1 / 0;
  } on IntegerDivisionByZeroException catch (e) {
    print(e);
  } on Exception {
    //捕获特定异常，不需要异常对象
  } catch (e) {
    //捕获所有异常
  }

  //在dart中可以抛出任意异常
  throw 12;
}
